from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from config.database import Base
from datetime import datetime

class BaGameRecord(Base):
    """
    账目记录表
    """

    __tablename__ = 'ba_game_record'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='ID')
    m_id = Column(Integer, ForeignKey('ba_machine.id'), nullable=True, default=None, comment='机器id')
    InCoin = Column(String(20), nullable=True, default=None, comment='投币')
    OpenNum = Column(String(20), nullable=True, default=None, comment='开分')
    InMoney = Column(String(20), nullable=True, default=None, comment='进钞')
    TotalInto = Column(String(20), nullable=True, default=None, comment='总进')
    TotalOut = Column(String(20), nullable=True, default=None, comment='总出')
    TotalPlayInto = Column(String(20), nullable=True, default=None, comment='总玩入')
    TotalPlayOut = Column(String(20), nullable=True, default=None, comment='总玩出')
    TotalPlayNum = Column(String(20), nullable=True, default=None, comment='总玩次数')
    TotalPlayWinNum = Column(String(20), nullable=True, default=None, comment='总赢次数')
    FreeGameCNum = Column(String(20), nullable=True, default=None, comment='免费游戏次数')
    WholeGameCNum = Column(String(20), nullable=True, default=None, comment='全盘游戏次数')
    SpecialRewardCNum = Column(String(20), nullable=True, default=None, comment='特殊奖励次数')
    OutCoin = Column(String(20), nullable=True, default=None, comment='退币')
    ClearNum = Column(String(20), nullable=True, default=None, comment='洗分')
    Lottery = Column(String(20), nullable=True, default=None, comment='彩票')
    TotalInOutBFB = Column(String(8), nullable=True, default=None, comment='总进总出百分比')
    TotalPlayInOutBFB = Column(String(8), nullable=True, default=None, comment='总玩入 总玩出百分比')
    TotalPlayWinNumOrPlayNumBFB = Column(String(8), nullable=True, default=None, comment='总玩次数 与 总赢次数百分比')
    FreeGameFNum = Column(String(20), nullable=True, default=None, comment='免费游戏分数')
    WholeGameFNum = Column(String(20), nullable=True, default=None, comment='全盘游戏分数')
    SpecialRewardFNum = Column(String(20), nullable=True, default=None, comment='特殊奖励分数')
    create_time = Column(Integer, nullable=True, default=datetime.now().timestamp(), comment='创建时间')

    machine = relationship("BaMachine", 
                         back_populates="game_records",
                         foreign_keys=[m_id])